import { IFeidaoAiBrowserComponent } from '@dfeidao/atom-web/interfaces';
import local_remove from '@dfeidao/atom-web/local/remove';
import local_set from '@dfeidao/atom-web/local/set';
import set_node_cls from '@dfeidao/atom-web/ui/set-node-cls';

import a002 from './a002';

// 初始化功能定义窗口弹出
export default async function a007(fd: IFeidaoAiBrowserComponent, args: { currentTarget: HTMLElement }) {
	const e = args.currentTarget;
	fd.data.node.querySelector<HTMLInputElement>('[data-feidao-id="seachkey123"]').value = '';
	const client_point_id = fd.data.node.querySelector<HTMLSelectElement>('[data-feidao-id="client_point_id"]').value;
	const group_number = e.getAttribute('group_number');
	const div_nodes = fd.data.node.querySelectorAll<HTMLDivElement>('[data-name="div"]');
	const div_node = fd.data.node.querySelector<HTMLDivElement>('[data-name="未分组"]');
	set_node_cls(div_node, 'bg-c', false);
	div_nodes.forEach((v) => {
		set_node_cls(v, 'bg-c', false);
	});
	set_node_cls(e, 'bg-c', true);
	local_set(fd, "client_point_id", client_point_id);
	local_set(fd, "group_number", group_number);
	local_remove(fd, "page_no");

	await a002(fd);
}
